/*
 * Textify.java
 *
 * Created on June 11, 2007, 7:27 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package afterburner.jsp.thrust;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author aris
 */
public class Textify {
    
    private static Map<Character, String>  entityMap;
    
    
    public static String html_escape(String text){
        if(text == null){
            return "";
        }
        //s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
        String s = text.replaceAll("&","&amp;").replaceAll("\"","&quot;").replaceAll(">","&gt;").replaceAll("<","&lt;").replaceAll("&","&amp;");
        return s.replaceAll("&amp;([a-z]+|(#\\d+));", "&#{$1};");
    }
    
   
    
    
    static{
        entityMap = new HashMap();
        entityMap.put('\u0391',"&#913;");
    }
}
